#include "model.h"
#include "mesh.h"

using namespace krryn::animation;
using namespace krryn::view;

size_t model::get_num_meshes(){
	return m_Meshes.size(); 
}

mesh *model::get_mesh(size_t i){
	return m_Meshes[i];
}

void model::set_bindpose(skeleton *a_Bindpose){
	m_Bindpose = a_Bindpose;
}

skeleton* model::get_bindpose() const{
	return m_Bindpose;
}

void model::add_mesh(mesh *a_Mesh){
	a_Mesh->set_parent(this);
	m_Meshes.push_back(a_Mesh);
}

void model::add_animation(const std::string &a_Name, krryn::animation::animation *a_Animation){
	m_Animations[a_Name] = a_Animation;
}

krryn::animation::animation *model::get_animation(const std::string &a_Name){
	auto i = m_Animations.find(a_Name);

	if(i != m_Animations.end()){
		return i->second;
	}

	throw std::runtime_error("Invalid animation requested " + a_Name);
}